var Connect = YAHOO.util.Connect,
Panel = YAHOO.widget.Panel,
KeyListener = YAHOO.util.KeyListener,
Event = YAHOO.util.Event,
Dom = YAHOO.util.Dom,
Json = YAHOO.lang.JSON;
var mainpage = 1;
var productOderType = '';
var productCat = 0;
var productMakerId = 0;
var countItem = 1;

var productMakerOrderType = '';
var productMakerCatId = 0;
var productMakerPage = 1;

var orderType = '';
var orderPage = 1;

var sliderType = '';
var sliderPage = 1;

var newsOrderType = '';
var newsCatNewsId = 0;
var newsCatSubId = 0;
var newsPage = 1;

var AdminController = {
    
    adminRequestFalse:function(){
        alert('AsyncRequest False');
    },
    setlectedTopMenu:function(elementId){
        var listEl = Dom.get('menu_top').getElementsByTagName('a');
        for(var i= 0; i < listEl.length; i++){
            if(listEl[i].className == 'cpointer selected'){
                listEl[i].className = listEl[i].className.replace('selected', 'noselect');
            }
        }
        if(Dom.get(elementId)){
            Dom.get(elementId).className = Dom.get(elementId).className.replace('noselect', 'selected');
        }
    },
    selectedHeaderControll:function(elementId){
        var listEl = Dom.get('manage-new-pland').getElementsByTagName('a');
        for(var i= 0; i < listEl.length; i++){
            if(listEl[i].className == 'selected'){
                listEl[i].className = '';
            }
        }
        if(Dom.get(elementId)){
            Dom.get(elementId).className = 'selected';
        }
    },
    hiddenLeftDiv:function(){
        var listDiv = Dom.get('left').getElementsByTagName('div');
        for(var i = 0; i < listDiv.length; i++){
            if(listDiv[i].className == 'show'){
                listDiv[i].className = 'hide';
            }
        }
    },

    selectOnchange:function(selectBoxParentId, inputIdList, selectboxChildId){
        var parentId = document.getElementById(selectBoxParentId).value;
        var strChild = document.getElementById(inputIdList).value;
        var childId =   document.getElementById(selectboxChildId);
        var childOpts = childId.options.length;
        //remove district
        for(var n = childOpts - 1; n > 0; n-- ){
            childId.removeChild(childId.options[n]);
        }
        var objDistrict = strChild.split('$');
        var districtLenght = objDistrict.length;
        //add new district option
        if(parentId != '0'){
            for(var i=0; i < districtLenght; i++){
                var aryChild = objDistrict[i].split(';');
                if(aryChild[2] == parentId){
                    var opt = document.createElement('OPTION');
                    opt.value = aryChild[0];
                    if(navigator.appName.indexOf('Microsoft') !=-1){
                        opt.innerText = aryChild[1];
                    }
                    else{
                        opt.text = aryChild[1];
                    }
                    childId.appendChild(opt);
                }
            }
            if(childId.options.length <= 1){
                childId.disabled = 'disabled';
            }else{
                childId.disabled = '';
            }
        }else{
            childId.disabled = 'disabled';
        }
    },

    selectOnClick:function(parentId, inputIdList, selectboxChildId){
        var strChild = document.getElementById(inputIdList).value;
        var childId =   document.getElementById(selectboxChildId);
        var childOpts = childId.options.length;
        //remove district
        for(var n = childOpts - 1; n > 0; n-- ){
            childId.removeChild(childId.options[n]);
        }
        var objDistrict = strChild.split('$');
        var districtLenght = objDistrict.length;
        //add new district option
        if(parentId != '0'){
            for(var i=0; i < districtLenght; i++){
                var aryChild = objDistrict[i].split(';');
                if(aryChild[2] == parentId){
                    var opt = document.createElement('OPTION');
                    opt.value = aryChild[0];
                    if(navigator.appName.indexOf('Microsoft') !=-1){
                        opt.innerText = aryChild[1];
                    }
                    else{
                        opt.text = aryChild[1];
                    }
                    childId.appendChild(opt);
                }
            }
            if(childId.options.length <= 1){
                childId.disabled = 'disabled';
            }else{
                childId.disabled = '';
            }
        }
        else{
            childId.disabled = 'disabled';
        }
    },

    backToTop:function(){
        window.scrollTo(0,0);
    },

    selectProductMakerOnChange:function(){
        AdminController.selectOnchange('product_category_id', 'list-product-maker-hide', 'product_maker_id');
    },

    selectProductMakerOnClick:function(parentId){
        AdminController.selectOnClick(parentId, 'list-product-maker-hide', 'product_maker_id');
    },

    selectNewsSub:function(){
        AdminController.selectOnchange('news_new_category_id', 'list_news_sub_hidden', 'news_new_sub_category_id');
    },

    selectCatInfo:function(productId){
        //        var catId = Dom.get('product_sub_category_id').value;
        Dom.get('product_cat_info_is_change').value = '';
        var strUrl = '/quanly/selectCatInfoByCatId/?ajax=1&catId='+catId+'&productId='+productId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.selectCatInfoSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    
    selectCatInfoSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('category-info').innerHTML = aryData.categoryInfo;
        }
        else{
            Dom.get('category-info').innerHTML = '';
        }
    },

    hiddenCenterDiv:function(){
        var listDiv = Dom.get('maincontentcenter').getElementsByTagName('div');
        for(var i = 0; i < listDiv.length; i++){
            if(listDiv[i].className == 'show'){
                listDiv[i].className = 'hide';
            }
        }
    },

    setElemnetLeftSelected:function(current){
        var listEl = Dom.get('left').getElementsByTagName('a');
        for(var i= 0; i < listEl.length; i++){
            if(listEl[i].className == 'selected'){
                listEl[i].className = listEl[i].className.replace('selected', '');
            }
        }
        if(Dom.get(current)){
            Dom.get(current).className = 'selected';
        }
    },

    manageProduct:function(){
        var elementId = 'menu_1';
        //        AdminController.setlectedTopMenu(elementId);
        
        AdminController.getListProduct('date-down', 0, 0, 1);
    },

    showPlandProduct:function(){
        var html = '';
        html += '<a id="title-list-product" onclick="AdminController.getListProduct();">Danh sách sản phẩm</a>';
        if(perProductAdd  == 1 || isMaster == 1){
            html += '<a id="title-add-product" onclick="AdminController.showEditorAddProduct();">Thêm sản phẩm</a>';
        }
        Dom.get('manage-new-pland').innerHTML = html;
    },

    getListProduct:function(oderType, catId, makerId, page){
        if(oderType == undefined){
            oderType = 'date-down';
        }
        if(catId == undefined){
            catId = 0;
        }
        if(page == undefined){
            page = 1;
        }
        if(makerId == undefined){
            makerId = 0;
        }
        mainpage = page;
        productOderType = oderType;
        productCat = catId;
        productMakerId = makerId;
        AdminController.showPlandProduct();
        var elementSubId = 'title-list-product';
        AdminController.selectedHeaderControll(elementSubId);
        AdminController.hiddenCenterDiv();
        AdminController.resetForm('frmAddProduct');
        
        var strPost = '';
        strPost+='perProductAdd='+perProductAdd+'&perProductEdit='+perProductEdit+'&perProductDelete='+perProductDelete+'&isMaster='+isMaster;
        var strUrl = '/quanly/getListProduct/?ajax=1&page='+page+'&orderType='+oderType+'&catId='+catId+'&makerId='+makerId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.getListProductSuccess,
            failure: AdminController.asyncRequestFalse
        },strPost);
    },

    getListProductSuccess:function(xmlhttp){
        var productCatId = Dom.get('product_category_id');
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        Dom.get('left-header').innerHTML = 'Quản lý theo danh mục';
        Dom.get('list-category').innerHTML = aryData.listCategory;
        Dom.get('list-product').className = 'show';
        Dom.get('list-product').innerHTML = aryData.listProduct;
//        Dom.get('list-product-maker-hide').value = aryData.listProductMaker;
        Dom.get('search_category_id').value = aryData.categoryId;
        
        var selectCatId = 'selectcatforadd1';

        var newsCatId = document.getElementById(selectCatId);
        
        var optLength = newsCatId.options.length;
        //remove district
        for(var n = optLength - 1; n >= 0; n--){
            newsCatId.removeChild(newsCatId.options[n]);
        }
        

        for (var property in aryData.aryCategory) {
            
            if (aryData.aryCategory.hasOwnProperty(property)) {
                try{
                    var opt = document.createElement('OPTION');
                    
                    opt.value = aryData.aryCategory[property]['category_id'];

                    var categoryName = aryData.aryCategory[property]['category_name'];

                    if(aryData.aryCategory[property]['category_total_child'] > 0){
                        categoryName+=' >';
                    }
                    if(navigator.appName.indexOf('Microsoft') !=-1){
                        opt.innerText = categoryName;
                    }
                    else{
                        opt.text = categoryName;
                    }
                    newsCatId.appendChild(opt);

                }
                catch(e){
                    alert(e.message);
                }
            }
        }
        
    },

    getListProductMaker :function(oderType, catId, page){
        if(oderType == undefined){
            oderType = 'name-up';
        }
        if(catId == undefined){
            catId = 0;
        }
        if(page == undefined){
            page = 1;
        }
        productMakerOrderType = oderType;
        productMakerCatId = catId;
        productMakerPage = page;
        var elementSubId = 'title-list-macker';

        AdminController.selectedHeaderControll(elementSubId);
        
        AdminController.hiddenCenterDiv();

        var strPost = '';
        strPost+='perProductAdd='+perProductAdd+'&perProductEdit='+perProductEdit+'&perProductDelete='+perProductDelete+'&isMaster='+isMaster;
        var strUrl = '/quanly/getListProductMaker/?ajax=1&page='+page+'&orderType='+oderType+'&catId='+catId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.getListProductMakerSuccess,
            failure: AdminController.asyncRequestFalse
        },strPost);
    },

    getListProductMakerSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        //        if(aryData.intOk == 1){
        Dom.get('list-product-maker').className = 'show';
        Dom.get('list-product-maker').innerHTML = aryData.listProductMaker;
        Dom.get('list-category').innerHTML = aryData.treeCategory;
    //        }
    },

    editProductMaker:function(makerCategoryId, productMakerId, categoryId, producMakerName){
        
        var elementSubId = 'xx';

        AdminController.selectedHeaderControll(elementSubId);

        AdminController.hiddenCenterDiv();
        
        var strUrl = '/quanly/getProductMakerById/?ajax=1&makerCategoryId='+makerCategoryId+'&productMakerId='+productMakerId+'&categoryId='+categoryId+'&producMakerName='+producMakerName;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.getProductMakerByIdSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },

    getProductMakerByIdSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        Dom.get('show-add-sub-cat').className = 'show';
        Dom.get('show-add-sub-cat').innerHTML = aryData.content;
        
        AdminController.putCategoryInSelect('product_maker', aryData.aryParentId);
        
    },

    selectProductSpecs:function(categoryId){
        var strPost = 'product_id='+Dom.get('product_id').value;
        var strUrl = '/quanly/selectProductSpecs/?ajax=1&categoryId='+categoryId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.selectProductSpecsSuccess,
            failure: AdminController.asyncRequestFalse
        },strPost);
    },

    selectProductSpecsSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('product_specs').innerHTML = aryData.listSpecs;
        }else{
            Dom.get('product_specs').innerHTML = '';
        }
    },

    putCategoryInSelect:function(type, aryData){
        var i = 1;
        for (var property in aryData) {
            if (aryData.hasOwnProperty(property)) {
                var n = parseInt(property)+1;
                AdminController.checkExistProductSubCategory(type, aryData[property], i, aryData[n]) ;
                i++;
            }
        }
    },

    manageCategory:function(){
        var elementId = 'menu_2';
        //        AdminController.setlectedTopMenu(elementId);
        var html = '';
        html += '<a id="title-cat-list" onclick="AdminController.manageCategory();">Danh sách danh mục</a>';
        if(perProductCategoryAdd == 1 || isMaster == 1){
            html += '<a id="title-cat-add-2" onclick="AdminController.showAddSubCategory();">Thêm danh mục</a>';
        }
        Dom.get('manage-new-pland').innerHTML = html;
        AdminController.hiddenCenterDiv();
        AdminController.getProductCategory(0,0);
    },

    manageSpecs:function(){
        var elementId = 'menu_2';
        //        AdminController.setlectedTopMenu(elementId);
        AdminController.hiddenCenterDiv();
        var html = '';
        html += '<a id="title-add-specs" onclick="AdminController.showAddSpecs();">Xem và thêm thông số</a>';
        Dom.get('manage-new-pland').innerHTML = html;
        AdminController.showAddSpecs();
    },

    showAddSpecs:function(){
        var elementId = 'title-add-specs';
        AdminController.hiddenCenterDiv();
        AdminController.selectedHeaderControll(elementId);
        var strUrl = '/quanly/showAddSpecs/?ajax=1';
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.showAddSubCategorySuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    
    getProductCategory:function(parentId, ulId){
        if(parentId == undefined){
            parentId = 0;
        }
        if(ulId == undefined){
            ulId = 0;
        }
        
        var elementId = 'title-cat-list';
        AdminController.selectedHeaderControll(elementId);
        var strPost = '';
        strPost+='perProductCategoryAdd='+perProductCategoryAdd+'&perProductCategoryEdit='+perProductCategoryEdit+'&perProductCategoryDelete='+perProductCategoryDelete+'&isMaster='+isMaster;
        var strUrl = '/quanly/getProductCategory/?ajax=1&parentCatId='+parentId+'&ulId='+ulId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.getProductCategorySuccess,
            failure: AdminController.asyncRequestFalse
        },strPost);
    },

    getProductCategorySuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        var maxUl = 4;
        for(var i = aryData.ulId; i < maxUl; i++){
            Dom.get('list_cat_'+i).innerHTML = '';
            Dom.get('list_cat_'+i).className = 'hide';
        }
        if(aryData.intOk == 1){
            Dom.get('list-content-category').className = 'show';
            Dom.get('left-header').innerHTML = 'Danh mục';
            Dom.get('list-category').innerHTML = aryData.listCategory;
            Dom.get('list_cat_'+aryData.ulId).className = 'show';
            Dom.get('list_cat_'+aryData.ulId).innerHTML = aryData.contentCategory;
            DDApp.init('ul_cat_'+aryData.ulId, 'product');
        }
        
    },

    selectedItemProductCategory:function(ulId, liId){
        var liItem = Dom.get('ul_cat_'+ulId).getElementsByTagName("li");
        var liItemLength = liItem.length;
        for(var i = 0; i < liItemLength;i++){
            liItem[i].className = 'list1';
        }
        Dom.get('li_cat_'+liId).className = 'list2';
    },

    orderProductCategory:function(ulId, type){
        var liItem = Dom.get(ulId).getElementsByTagName("li");
        var liITemLength = liItem.length;
        var strLiId = '';
        for(var i = 0; i < liITemLength; i++){
            strLiId+=liItem[i].id+',';
        }
        if(type == 'product'){

            var strUrl = '/quanly/orderProductCategory/?ajax=1&strLiId='+strLiId;
        }
        if(type == 'news'){
            
            var strUrl = '/quanly/orderNewsCategory/?ajax=1&strLiId='+strLiId;
        }

        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.orderProductCategorySuccess,
            failure: AdminController.asyncRequestFalse
        });
        
    },

    orderProductCategorySuccess:function(){

    },

    manageProductMaker:function(){
        var elementId = 'menu_2';
        //        AdminController.setlectedTopMenu(elementId);
        AdminController.hiddenCenterDiv();
        var html = '';
        html += '<a id="title-list-macker" onclick="AdminController.getListProductMaker();">Danh sách hãng sản xuất</a>';
        if(perProductCategoryAdd == 1 || isMaster == 1){
            html += '<a id="title-add-maker" onclick="AdminController.showAddProductMaker();">Thêm hãng sản xuất</a>';
        }
        Dom.get('manage-new-pland').innerHTML = html;
        AdminController.getListProductMaker();
    },

    showAddProductMaker:function(){
        var elementId = 'title-add-maker';
        AdminController.hiddenCenterDiv();
        AdminController.selectedHeaderControll(elementId);
        var strUrl = '/quanly/showAddProductMaker/?ajax=1';
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.showAddSubCategorySuccess,
            failure: AdminController.asyncRequestFalse
        });
    },

    saveProductMaker:function(type){
        var strUrl = '/quanly/saveProductMaker/?ajax=1&type='+type;
        YAHOO.util.Connect.setForm('frmAddProductMaker', true);
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            upload: AdminController.saveProductMakerSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },

    saveProductMakerSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        
        if(aryData.intOk == 1){
            //            AdminController.showOverlaySuccess(aryData.successMessage);
            //            AdminController.showOverlayConfirmYesNo('Hãng sản xuất đã được thêm. Bán có muốn tiếp tục?', 'AdminController.showAddProductMaker();', 'AdminController.getListProductMaker();');
            AdminController.showOverlaySuccess(aryData.successMessage);
            if(aryData.type == 'add'){
                AdminController.getListProductMaker('id-down', 0, 1);
            }else{
                AdminController.getListProductMaker(productMakerOrderType, productMakerCatId, productMakerPage);
            }
            
        }else{
            AdminController.showOverlayError(aryData.strError);
        }
    },

    manageNewsCategory:function(){
        var elementId = 'menu_4';
        AdminController.hiddenCenterDiv();
        var html = '';
        html += '<a id="title-news-list-cat" onclick="AdminController.manageNewsCategory();">Danh sách danh mục</a>';
        if(perNewsCategoryAdd == 1 || isMaster == 1){
            html += '<a id="title-news-add-cat" onclick="AdminController.showAddCategoryNews();">Thêm danh mục</a>';
        }
        Dom.get('manage-new-pland').innerHTML = html;
        AdminController.getListNewsCategory();
        
    },

    getListNewsCategory:function(parentId, ulId){
        if(parentId == undefined){
            parentId = 0;
        }
        if(ulId == undefined){
            ulId = 0;
        }
        var elementId = 'title-news-list-cat';
        this.selectedHeaderControll(elementId);
        var strPost = 'perNewsCategoryAdd='+perNewsCategoryAdd+'&perNewsCategoryEdit='+perNewsCategoryEdit+'&perNewsCategoryDelete='+perNewsCategoryDelete+'&isMaster='+isMaster
        var strUrl = '/quanly/getNewsCategory/?ajax=1&parentCatId='+parentId+'&ulId='+ulId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.getListNewsCategorySuccess,
            failure: AdminController.asyncRequestFalse
        },strPost);
    },

    getListNewsCategorySuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        var maxUl = 2;
        for(var i = aryData.ulId; i < maxUl; i++){
            Dom.get('news_cat_item_'+i).innerHTML = '';
            Dom.get('news_cat_item_'+i).className = 'hide';
        }
        Dom.get('product_cat_option').innerHTML = aryData.catOption;
        if(aryData.intOk == 1){
            Dom.get('list-news-category').className = 'show';
            //            Dom.get('list-category').innerHTML = aryData.listNewsCategory;
            Dom.get('news_cat_item_'+aryData.ulId).className = 'show';
            Dom.get('news_cat_item_'+aryData.ulId).innerHTML = aryData.contentNewsCategory;
            DDApp.init('ul_cat_'+aryData.ulId, 'news');
        }
        Dom.get('product_category_id').value = aryData.news_product_category;
    },

    showAddCategoryNews:function(){
        var elementId = 'title-news-add-cat';
        AdminController.hiddenCenterDiv();
        AdminController.selectedHeaderControll(elementId);
        var strUrl = '/quanly/showAddCategoryNews/?ajax=1';
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.showAddCategoryNewsSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },

    showAddCategoryNewsSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        Dom.get('addCategoryNews').className = 'show';
        Dom.get('addCategoryNews').innerHTML = aryData.content;
    },

    saveNewsCategory:function(){
        var strUrl = '/quanly/saveNewsCategory/?ajax=1';
        YAHOO.util.Connect.setForm('frmAddCategoryNews');
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.saveNewsCategorySuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },

    saveNewsCategorySuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
            AdminController.manageNewsCategory();
        }else{
            AdminController.showOverlayError(aryData.strError);
        }
    },

    manageNews:function(){
        AdminController.getListNews();
    },

    showPlandNews:function(){
        var html = '';
        html += '<a id="title-list-news" onclick="AdminController.getListNews();">Danh sách tin</a>';
        if(perNewsAdd == 1 || isMaster == 1){
            html += '<a id="title-add-news" onclick="AdminController.showEditorAddNews();">Thêm tin mới</a>';
        }
        Dom.get('manage-new-pland').innerHTML = html;
    },

    getListNews:function(oderType, newsCatId, newsSubId, page){

        AdminController.showPlandNews();

        if(oderType == undefined){
            oderType = 'date-down';
        }
        if(newsCatId == undefined){
            newsCatId = 0;
        }
        if(newsSubId == undefined){
            newsSubId = 0;
        }
        if(page == undefined){
            page = 1;
        }

        newsOrderType = oderType;
        newsCatNewsId = newsCatId;
        newsCatSubId = newsSubId;
        newsPage = page;

        

        var elementId = 'title-list-news';

        this.selectedHeaderControll(elementId);

        AdminController.hiddenCenterDiv();

        AdminController.resetForm('frmAddNews');
        
        var strPost = '';
        strPost += 'perNewsAdd='+perNewsAdd+'&perNewsEdit='+perNewsEdit+'&perNewsDelete='+perNewsDelete+'&isMaster='+isMaster;
        var strUrl = '/quanly/getListNews/?ajax=1&page='+page+'&orderType='+oderType+'&newCatId='+newsCatId+'&newsSubId='+newsSubId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.getListNewsSuccess,
            failure: AdminController.asyncRequestFalse
        },strPost);
    },

    getListNewsSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        Dom.get('list-news').className = 'show';
        Dom.get('list-news').innerHTML = aryData.listNews;
        Dom.get('list-category').innerHTML = aryData.listNewsCategory;
        Dom.get('list_news_sub_hidden').value = aryData.strListNewsSubCat;

        var newsCatId = Dom.get('news_new_category_id');
        
        var districtOpts = newsCatId.options.length;
        //remove district
        for(var n = districtOpts - 1; n > 0; n-- ){
            newsCatId.removeChild(newsCatId.options[n]);
        }
        for (var property in aryData.jsonNewsCategory) {
            if (aryData.jsonNewsCategory.hasOwnProperty(property)) {
                try{
                    var opt = document.createElement('OPTION');
                    opt.value = aryData.jsonNewsCategory[property]['news_category_id'];
                    if(navigator.appName.indexOf('Microsoft') !=-1){
                        opt.innerText = aryData.jsonNewsCategory[property]['news_category_name'];
                    }else{
                        opt.text = aryData.jsonNewsCategory[property]['news_category_name'];
                    }
                    newsCatId.appendChild(opt);
                //                    alert(aryData.jsonCategory[property]['pmico_category_name']);
                }catch(e){
                    alert(e.message);
                }
            }
        }
        
    },

    showEditorAddNews:function(){
        AdminController.hiddenCenterDiv();
        AdminController.clearError();
        AdminController.resetForm('frmAddNews');
        var elementId = 'title-add-news';
        this.selectedHeaderControll(elementId);
        document.getElementById('submitAddNews').value = 'Đăng tin';
        document.getElementById('submitAddNews').setAttribute('onclick', "AdminController.saveNews('add');");
        Dom.get('editor-add-news').className = 'show';
    },

    addRowItemCategory:function(itemId, hiddenId){
        var parentId = document.getElementById(itemId);
        var listInputHidden = document.getElementById(hiddenId);
        var newDiv = document.createElement('div');
        newDiv.id = 'item-'+countItem;
        newDiv.innerHTML = listInputHidden.innerHTML;
        parentId.appendChild(newDiv)
        countItem++;
    },

    removeRowItemCategory:function(itemId , parentId){
        var listItem = document.getElementById(parentId).getElementsByTagName('div');
        if(listItem.length == 1){
            return;
        }
        var currentId = itemId.parentNode.parentNode;
        var parent = document.getElementById(parentId);
        parent.removeChild(currentId);
        
    },

    showAddSubCategory:function(){
        var elementId = 'title-cat-add-2';
        AdminController.hiddenCenterDiv();
        AdminController.selectedHeaderControll(elementId);
        var strUrl = '/quanly/showAddSubCategory/?ajax=1';
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.showAddSubCategorySuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    
    showAddSubCategorySuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        Dom.get('show-add-sub-cat').className = 'show';
        Dom.get('show-add-sub-cat').innerHTML = aryData.content;
    },

    showProductMakerForAddMaker:function(categoryId){
        var strUrl = '/quanly/showProductMakerForAddMaker/?ajax=1&categoryId='+categoryId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.showProductMakerSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },

    showProductMakerSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.hasProductMaker == 1){
            Dom.get('list_current_product_maker').innerHTML = aryData.aryCurrentProductMaker;
        }
        else{
            Dom.get('list_current_product_maker').innerHTML = '';
        }
    },

    showSpecsByCatId:function(categoryId){
        Dom.get('btnSumitSpecs').className = 'hide';
        Dom.get('list_input_specs').innerHTML = '';

        var strUrl = '/quanly/showSpecsByCatId/?ajax=1&categoryId='+categoryId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.showSpecsByCatIdSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },

    showSpecsByCatIdSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('list_specs').innerHTML = aryData.listSpecs;
        }else{
            Dom.get('list_specs').innerHTML = '';
        }
    },

    saveSpecs:function(type){
        var strUrl = '/quanly/saveSpecs/?ajax=1&type='+type;
        YAHOO.util.Connect.setForm('frmAddSpecs');
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.saveSpecsSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },

    saveSpecsSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.messageSuccess);
        //            AdminController.getProductCategory();
        }else{
            AdminController.showOverlayError(aryData.strError);
        }
    },
    
    saveMainCategory:function(){
        var strUrl = '/quanly/saveMainCategory/?ajax=1';
        YAHOO.util.Connect.setForm('frmAddNewCategory');
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.saveMainCategorySuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    
    saveMainCategorySuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            alert('Danh mục cấp 1 đã được tạo.');
        }
        else{
            alert('Vui lòng nhập tên danh mục.');
        }
    },

    saveSubCategory:function(){
        var strUrl = '/quanly/saveSubCategory/?ajax=1';
        YAHOO.util.Connect.setForm('frmAddSubCatCategory', true);
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            upload: AdminController.saveSubCategorySuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    
    saveSubCategorySuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            //            AdminController.showOverlaySuccess(aryData.successMessage);
            //            AdminController.showOverlayConfirmYesNo('Danh mục đã được lưu bạn có muốn tiếp tục', 'AdminController.showAddSubCategory();', 'AdminController.getProductCategory();');
            AdminController.showOverlaySuccess("Danh mục sản phẩm đã được thêm.");
            AdminController.manageCategory();
        }else{
            AdminController.showOverlayError(aryData.strError);
        }
    },

    saveNewsSubCategory:function(){
        var strUrl = '/quanly/saveNewsSubCategory/?ajax=1';
        YAHOO.util.Connect.setForm('frmOverlayAddNewsSubCategory');
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.saveNewsSubCategorySuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    saveNewsSubCategorySuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            alert('Danh mục tin tức cấp 2 đã được lưu.');
            AdminController.closeOverlayAddNewsSubCat();
            AdminController.manageNewsCategory();
        }else{
            alert('Bạn chưa nhập tên danh mục tin tức cấp 2.');
        }
    },

    showOverlaySuccess:function(messageSuccess){
        AdminController.backToTop();
        Dom.get('confirm-header').innerHTML = 'Thành công';
        Dom.get('confirm-message').innerHTML = messageSuccess;
        AdminController.showOverlayConfirm();
    },

    showOverlayError:function(messageError){
        AdminController.backToTop();
        Dom.get('confirm-header').innerHTML = 'Có lỗi xảy ra';
        Dom.get('confirm-message').innerHTML = messageError;
        AdminController.showOverlayConfirm();
    },

    showOverlayConfirm:function(){
        AdminController.overlayConfirm = new YAHOO.widget.Panel('overlayConfirm',
        {
            fixedcenter:true,
            close:false,
            visible:false,
            draggable:false,
            modal:false,
            width:"400px",
            zIndex: 255
        });

        // Render the Dialogs
        AdminController.overlayConfirm.render(document.body);
        AdminController.overlayConfirm.center();
        document.getElementById('overlayConfirm').style.display = 'block';
        AdminController.overlayConfirm.show();
    },

    closeOverlayConfirm:function(){
        AdminController.overlayConfirm.hide();
    },

    showOverlayConfirmYesNo:function(message, actClickYes, actClickNo){
        AdminController.backToTop();
        Dom.get('confirm-header-yes-no').innerHTML = 'Xác nhận';
        Dom.get('confirm-message-yes-no').innerHTML = message;
        AdminController.overlayConfirmYesNo();
        document.getElementById('confirm-yes').setAttribute('onclick', 'AdminController.closeOverlayConfirmYesNo();'+actClickYes);
        document.getElementById('confirm-no').setAttribute('onclick', 'AdminController.closeOverlayConfirmYesNo();'+actClickNo);
    },

    overlayConfirmYesNo:function(){
        var x = 450;
        var y = 100;
        AdminController.confirmYesNo = new YAHOO.widget.Panel('overlayConfirmYesNo',
        {
            xy:[x,y],
            //            fixedcenter:true,
            close:false,
            visible:false,
            draggable:false,
            modal:true,
            width:"400px",
            zIndex: 255
        });

        // Render the Dialogs
        AdminController.confirmYesNo.render(document.body);
        //        AdminController.overlayConfirmYesNo.center();
        document.getElementById('overlayConfirmYesNo').style.display = 'block';
        AdminController.confirmYesNo.show();
    },

    closeOverlayConfirmYesNo:function(){
        AdminController.confirmYesNo.hide();
    },

    showOverlayAddSub:function(catId, catName){
        var html;
        html = 'Thêm danh mục cấp 2 cho danh mục '+catName;
        Dom.get('category-header').innerHTML = html;
        Dom.get('cat_id_hidden').value = catId;
        AdminController.overlayAddSubCat = new YAHOO.widget.Panel('overlayAddSubCat',
        {
            fixedcenter:true,
            //            xy:[500,100],
            constraintoviewport:true,
            underlay:"none",
            close:true,
            visible:false,
            draggable:false,
            modal:true,
            width:"700px",
            zIndex: 255
        });

        // Render the Dialogs
        AdminController.overlayAddSubCat.render(document.body);
        AdminController.overlayAddSubCat.center();
        //        MyController.overlayRegister.cfg.setProperty("y", 14);
        document.getElementById('overlayAddSubCat').style.display = 'block';
        AdminController.overlayAddSubCat.show();
    },

    closeOverlayAddSubCat:function(){
        if(AdminController.overlayAddSubCat.hide){
            AdminController.overlayAddSubCat.hide();
        }
    },

    showOverlayAddNewsSub:function(catId, catName){
        var html;
        html = 'Thêm danh mục tin tức cấp 2 cho danh mục '+catName;
        Dom.get('category-news-header').innerHTML = html;
        Dom.get('cat_news_id_hidden').value = catId;
        AdminController.overlayAddNewsSubCat = new YAHOO.widget.Panel('overlayAddNewsSubCat',
        {
            fixedcenter:true,
            //            xy:[500,100],
            constraintoviewport:true,
            underlay:"none",
            close:true,
            visible:false,
            draggable:false,
            modal:true,
            width:"700px",
            zIndex: 255
        });

        // Render the Dialogs
        AdminController.overlayAddNewsSubCat.render(document.body);
        AdminController.overlayAddNewsSubCat.center();
        //        MyController.overlayRegister.cfg.setProperty("y", 14);
        document.getElementById('overlayAddNewsSubCat').style.display = 'block';
        AdminController.overlayAddNewsSubCat.show();
    },

    closeOverlayAddNewsSubCat:function(){
        if(AdminController.overlayAddNewsSubCat.hide){
            AdminController.overlayAddNewsSubCat.hide();
        }
    },

    showOverlayAddCatInfo:function(catId, catName){
        var html;

        html = 'Thông số của danh mục '+catName;

        Dom.get('cat-info-header').innerHTML = html;

        Dom.get('cat_id_info').value = catId;

        AdminController.overlayAddCatInfo = new YAHOO.widget.Panel('overlayAddCategoryIndo',
        {
            fixedcenter:true,
            //            xy:[500,100],
            constraintoviewport:true,
            underlay:"none",
            close:true,
            visible:false,
            draggable:false,
            modal:true,
            width:"700px",
            zIndex: 255
        });

        // Render the Dialogs
        AdminController.overlayAddCatInfo.render(document.body);
        AdminController.overlayAddCatInfo.center();
        //        MyController.overlayRegister.cfg.setProperty("y", 14);
        document.getElementById('overlayAddCategoryIndo').style.display = 'block';
        AdminController.overlayAddCatInfo.show();
        AdminController.viewCatInfoByCatId();
    },

    closeOverlayAddCatInfo:function(){
        if(AdminController.overlayAddCatInfo.hide){
            AdminController.overlayAddCatInfo.hide();
        }
    },

    selectedHeaderCatInfo:function(elementId){
        var listEl = Dom.get('title-cat-info').getElementsByTagName('a');
        for(var i= 0; i < listEl.length; i++){
            listEl[i].className = '';
        }
        if(Dom.get(elementId)){
            Dom.get(elementId).className = 'selected';
        }
    },

    viewCatInfoByCatId:function(){
        var elementId = 'title-cat-info-1';
        AdminController.selectedHeaderCatInfo(elementId);
        Dom.get('form-input-cat-info').className = 'hide';
        Dom.get('list-cat-info').className = 'show';
        var catId = Dom.get('cat_id_info').value;
        var strPost = 'catId='+catId;
        strPost+='&perProductCategoryAdd='+perProductCategoryAdd+'&perProductCategoryEdit='+perProductCategoryEdit+'&perProductCategoryDelete='+perProductCategoryDelete+'&isMaster='+isMaster;
        var strUrl = '/quanly/getCatInfoByCatId/?ajax=1';
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.getCatInfoByCatIdSuccess,
            failure: AdminController.asyncRequestFalse
        },strPost);

    },
    getCatInfoByCatIdSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('list-cat-info').innerHTML = aryData.content;
        }else{

    }
    },
    showFormAddCatInfo:function(elementId){
        AdminController.selectedHeaderCatInfo(elementId);
        Dom.get('form-input-cat-info').className = 'show form-overlay';
        Dom.get('list-cat-info').className = 'hide';
    },
    saveCatInfo:function(){
        var strUrl = '/quanly/saveCategoryInfo/?ajax=1';
        YAHOO.util.Connect.setForm('frmOverlayAddCategoryInfo');
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.saveCatInfoSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    saveCatInfoSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            alert('Thông số đã được thêm.');
            AdminController.viewCatInfoByCatId();
        }else{
            alert(aryData.error);
        }
    },

    saveCatInfoLevel3:function(){
        var strUrl = '/quanly/saveCategoryInfoLevel3/?ajax=1';
        YAHOO.util.Connect.setForm('frmOverlayAddCategoryInfoLevel3');
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.saveCatInfoLevel3Success,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },

    saveCatInfoLevel3Success:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            alert('Thông số cấp 3 đã được thêm.');
            AdminController.closeOverlayAddSubCatInfoLevel3();
            AdminController.viewCatInfoByCatId('title-cat-info-1');
        }else{
            alert(aryData.error);
        }
    },

    saveSubCatInOverlay:function(){
        var strUrl = '/quanly/saveSubCatInOverlay/?ajax=1';
        YAHOO.util.Connect.setForm('frmOverlayAddCategory');
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.saveCatInOverlaySuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },

    saveCatInOverlaySuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            alert('Danh mục đã được lưu.');
            AdminController.closeOverlayAddSubCat();
            AdminController.getProductCategory();
        }else{
            alert("Bạn chưa nhập tên danh mục sản phẩm cấp 2.");
        }
    },
    showEditCategory:function(catId){
        Dom.get('edit_cat_'+catId).className = 'show';
    },

    showEditNewsCategory:function(catId){
        Dom.get('news-cat-'+catId).className = 'hide';
        Dom.get('news-input-'+catId).className = 'show list-category';
    },

    closeEditCatById :function(catId){
        Dom.get('edit_cat_'+catId).className = 'hide';
    },
    showEditCategoryInfo:function(catId){
        Dom.get('list-cat-info-'+catId).className = 'hide';
        Dom.get('sub-input-cat-info-'+catId).className = 'show list-category';
    },
    closeEditCatInfoById :function(catId){
        Dom.get('list-cat-info-'+catId).className = 'show list-category';
        Dom.get('sub-input-cat-info-'+catId).className = 'hide';
    },
    saveCategoryById:function(catId, ulId, parentId){
        var strUrl = '/quanly/editCategoryById/?ajax=1';
        var categoryName = Dom.get('input_cat_'+catId).value;
        var strPost = 'categoryName='+categoryName;
        strPost+='&categoryId='+catId;
        strPost+='&ulId='+ulId;
        strPost+='&parentId='+parentId;
        YAHOO.util.Connect.setForm('frmCat'+catId, true);
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            upload: AdminController.saveCategoryByIdSuccess,
            failure: AdminController.asyncRequestFalse
        },strPost);
    },
    saveCategoryByIdSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
            AdminController.getProductCategory(aryData.parentId, aryData.ulId);
        }
    },
    
    saveCategoryInfoById:function(catId){
        var strUrl = '/quanly/saveCategoryInfoById/?ajax=1';
        var categoryInfoName = Dom.get('info-'+catId).value;
        var strPost = 'categoryInfoName='+categoryInfoName;
        strPost+='&categoryId='+catId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.saveCategoryInfoByIdSuccess,
            failure: AdminController.asyncRequestFalse
        },strPost);
    },
    saveCategoryInfoByIdSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            alert('Thông số đã được cập nhật.');
            AdminController.viewCatInfoByCatId('title-cat-info-1');
        }
    },
    showOverlayAddSubCatInfo:function(catId, catName){
        var html;

        html = 'Thêm thông số cấp 2 cho thông số '+catName;

        Dom.get('category-info-header').innerHTML = html;

        Dom.get('cat_level_1').value = Dom.get('cat_id_info').value;
        Dom.get('cat_level_2').value = catId;

        AdminController.overlayAddSubCatInfo = new YAHOO.widget.Panel('overlayAddSubCatInfo',
        {
            fixedcenter:true,
            //            xy:[500,100],
            constraintoviewport:true,
            underlay:"none",
            close:true,
            visible:false,
            draggable:false,
            modal:true,
            width:"700px",
            zIndex: 255
        });

        // Render the Dialogs
        AdminController.overlayAddSubCatInfo.render(document.body);
        AdminController.overlayAddSubCatInfo.center();
        //        MyController.overlayRegister.cfg.setProperty("y", 14);
        document.getElementById('overlayAddSubCatInfo').style.display = 'block';
        AdminController.overlayAddSubCatInfo.show();
    },

    closeOverlayAddSubCatInfo:function(){
        if(AdminController.overlayAddSubCatInfo.hide){
            AdminController.overlayAddSubCatInfo.hide();
        }
    },

    showOverlayAddSubCatInfoLevel3:function(catId, catName){
        var html;

        html = 'Thêm thông số cấp 3 cho thông số '+catName;

        Dom.get('cat-info-header-level3').innerHTML = html;

        Dom.get('parent_category_id').value = Dom.get('cat_id_info').value;
        Dom.get('cat_id_info_level_2').value = catId;

        AdminController.overlayAddSubCatInfoLevel3 = new YAHOO.widget.Panel('overlayAddCategoryIndoLevel3',
        {
            fixedcenter:true,
            //            xy:[500,100],
            constraintoviewport:true,
            underlay:"none",
            close:true,
            visible:false,
            draggable:false,
            modal:true,
            width:"700px",
            zIndex: 255
        });

        // Render the Dialogs
        AdminController.overlayAddSubCatInfoLevel3.render(document.body);
        AdminController.overlayAddSubCatInfoLevel3.center();
        //        MyController.overlayRegister.cfg.setProperty("y", 14);
        document.getElementById('overlayAddCategoryIndoLevel3').style.display = 'block';
        AdminController.overlayAddSubCatInfoLevel3.show();
    },

    closeOverlayAddSubCatInfoLevel3:function(){
        if(AdminController.overlayAddSubCatInfoLevel3.hide){
            AdminController.overlayAddSubCatInfoLevel3.hide();
        }
    },
    
    saveSubCatInfo:function(){
        var strUrl = '/quanly/saveSubCatInfo/?ajax=1';
        YAHOO.util.Connect.setForm('frmOverlayAddSubCategoryInfo');
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.saveSubCatInfoSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    
    saveSubCatInfoSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            alert('Thông số cấp 2 đã được thêm.');
            AdminController.closeOverlayAddSubCatInfo();
            AdminController.viewCatInfoByCatId('title-cat-info-1');
        }
        else{
            alert(aryData.error);
        }
    },
    
    deleteCategoryById:function(catId, ulId, parentCatId){
        
        //        if(confirm('Bạn chắc chắn muốn xóa danh mục này?') == false){
        //            return;
        //        }
        var strUrl = '/quanly/deleteCategoryById/?ajax=1&catId='+catId+'&ulId='+ulId+'&parentId='+parentCatId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.deleteCategoryByIdSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    
    deleteCategoryByIdSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
            AdminController.getProductCategory(aryData.parentId, aryData.ulId);
            
        }
    },

    deleteNewsCategoryById:function(catId){
        
        if(confirm('Bạn chắc chắn muốn xóa danh mục này?') == false){
            return;
        }
        var strUrl = '/quanly/deleteNewsCategoryById/?ajax=1';
        var strPost = 'catId='+catId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.deleteNewsCategoryByIdSuccess,
            failure: AdminController.asyncRequestFalse
        },strPost);
    },

    deleteNewsCategoryByIdSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            alert('Danh mục đã được xóa.');
            AdminController.manageNewsCategory();
        }
    },

    resetForm:function(formId){
        document.getElementById(formId).reset();
    },
    
    showEditorAddProduct:function(){
        AdminController.clearError();
        AdminController.hiddenCenterDiv();
//        Dom.get('product_specs').innerHTML = '';
//        Dom.get('change_price_1').innerHTML = '';
//        Dom.get('change_price_2').innerHTML = '';
//        Dom.get('change_price_usd').innerHTML = '';
        AdminController.resetForm('frmAddProduct');
        Dom.get('product_category_id_hidden').value = '';
        Dom.get('product_id').value = '';
        Dom.get('product_cat_info_is_change').value = '';
        Dom.get('editor').className = 'show';
        var elementSubId = 'title-add-product';
        AdminController.selectedHeaderControll(elementSubId);
        document.getElementById('submitMemberPost').value = 'Đăng sản phẩm';
        document.getElementById('submitMemberPost').setAttribute('onclick', "AdminController.saveProduct('add');");
    },

    clearError:function(){
        var elementError = Dom.getElementsByClassName('validate_error');
        var errorLenght = elementError.length;
        for(var i = 0; i < errorLenght; i++){
            elementError[i].style.display = 'none';
        }
    },
    
    saveProduct:function(type){
        AdminController.clearError();
        var content= tinyMCE.get('product_content').getContent();
        var productHighlight = tinyMCE.get('product_content').getContent();
//        var productPromotional = tinyMCE.get('product_promotional').getContent();
        Dom.get('product_content').value = content;
        Dom.get('product_highlight').value = productHighlight;
//        Dom.get('product_promotional').value = productPromotional;
//        var strPost = 'product_store_name='+Common.getSelectText('product_store_id');
//        strPost+='&product_warranty_name='+Common.getSelectText('product_warranty_id');
//        strPost+='&product_origin_name='+Common.getSelectText('product_origin_id');
//        strPost+='&product_transportation_name='+Common.getSelectText('product_transportation_id');
//        if(Dom.get('product_maker_id') != ''){
//            strPost+='&product_maker_name='+Common.getSelectText('product_maker_id');
//        }
//        strPost+='&product_type_name='+Common.getSelectText('product_type_id');
        var strUrl = '/quanly/saveProduct/?ajax=1&type='+type;
        YAHOO.util.Connect.setForm('frmAddProduct', true);
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            upload: AdminController.saveProductSuccess,
            failure: AdminController.adminRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    
    saveProductSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            if(aryData.type == 'add'){
                
                //                AdminController.getListProduct();
                //            AdminController.showOverlaySuccess('xx');
                //                AdminController.overlayConfirmYesNo();
                AdminController.showOverlayConfirmYesNo(aryData.message, 'AdminController.showEditorAddProduct();', 'AdminController.getListProduct();');
            //                AdminController.getListProduct();
            }else{
                //                AdminController.showOverlayConfirmYesNo('Sản phẩm đã được thêm. Bạn có muốn tiếp tục đăng sản phâm?', 'AdminController.showEditorAddProduct();', 'AdminController.getListProduct();');
                AdminController.getListProduct(productOderType, productCat, productMakerId, mainpage);
                AdminController.showOverlaySuccess(aryData.message);
            }
        }else{
            AdminController.showOverlayError('Bạn chưa nhập đủ dữ liệu hoặc dữ liệu nhập vào bị sai.');
            AdminController.innerError(aryData.aryError);
            
        }
    },

    deleteProduct:function(productId){
        if(confirm('Bạn chắc chắn muốn xóa sản phẩm này?') == false){
            return;
        }
        var strUrl = '/quanly/deleteProduct/?ajax=1&productId='+productId+'&page='+mainpage+'&categoryId='+productCat;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.deleteProductSuccess,
            failure: AdminController.adminRequestFalse
        });
    },

    deleteProductSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.messageDeleteSuccess);
            AdminController.getListProduct(productOderType, productCat, productMakerId, aryData.page);
        }
    },

    innerError:function(aryErrorData){
        
        for (var property in aryErrorData) {
            if (aryErrorData.hasOwnProperty(property)) {
                try{
                    document.getElementById(property).style.display = 'inline';
                    document.getElementById(property).innerHTML = aryErrorData[property];
                }catch(e){
                    alert(e.message);
                }
            }
        }
    },
    
    editProduct:function(productId, categoryId){
        AdminController.hiddenCenterDiv();
        AdminController.clearError();
        Dom.get('product_specs').innerHTML = '';
        var html = '<span>Cập nhật sản phẩm</span>';
        html+='<span style="cursor:pointer;margin-left:20px;color:red; text-decoration: underline;" onclick="AdminController.hideProductEditor();">Đóng</span>';
        Dom.get('manage-new-pland').innerHTML = html;
        Dom.get('submitMemberPost').value = 'Cập nhật';
        document.getElementById('submitMemberPost').setAttribute('onclick', "AdminController.saveProduct('edit');");
        document.getElementById('editor').className = 'show';
        Dom.get('product_id').value = productId;
        var strUrl = '/quanly/getDataForEditProduct/?ajax=1&productId='+productId+'&categoryId='+categoryId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.getDataProductSuccess,
            failure: AdminController.adminRequestFalse
        });
    },

    getDataProductSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Common.jsonToForm(aryData.data);
//            if(aryData.data.product_promotional){
//                tinyMCE.get('product_promotional').setContent(aryData.data.product_promotional);
//            }else{
//                tinyMCE.get('product_promotional').setContent('');
//            }
            if(aryData.data.product_highlight){
                tinyMCE.get('product_highlight').setContent(aryData.data.product_highlight);
            }else{
                tinyMCE.get('product_highlight').setContent('');
            }
            if(aryData.data.product_content){
                tinyMCE.get('product_content').setContent(aryData.data.product_content);
            }else{
                tinyMCE.get('product_content').setContent('');
            }
//            Dom.get('product_maker_id').value = aryData.data.product_maker_id;
//            Dom.get('datepicker1').value = aryData.product_promotional_from;
//            Dom.get('datepicker2').value = aryData.product_promotional_to;
            Dom.get('product_category_id_hidden').value = aryData.data.product_category_id;
            Dom.get('selectcatforadd1').value = aryData.aryParentId[0];
//            AdminController.selectProductMakerOnClick(aryData.data.product_category_id);
//            Dom.get('product_maker_id').value = aryData.data.product_maker_id;
            AdminController.putCategoryInSelect('product', aryData.aryParentId);
            AdminController.selectProductSpecs(aryData.data.product_category_id);
        }
    },

    checkCatInfoChange:function(){
        Dom.get('product_cat_info_is_change').value = 1;
    },

    checkExistProductSubCategory:function(type, catId, selectId, nextCatId){
        if(nextCatId == undefined){
            nextCatId = 0;
        }
        var categoryHidden = '';
        if(type == 'product_maker'){
            categoryHidden = 'category_id_hidden';
            
        }else if(type == 'product'){
            categoryHidden = 'product_category_id_hidden';
        }else if(type == 'specs'){
            categoryHidden =  'specs_category_id'
        }
        Dom.get(categoryHidden).value = catId;
        var strUrl = '/quanly/checkExistProductSubCategory/?ajax=1&selectId='+selectId+'&categoryId='+catId+'&type='+type+'&nextCatId='+nextCatId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.checkProSubCatSuccess,
            failure: AdminController.adminRequestFalse
        });
    },

    checkProSubCatSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        var divCat = '';
        var selectCat = '';
        if(aryData.type == 'product_maker'){
            divCat = 'cat_';
            selectCat = 'selectcat';
        }else if(aryData.type == 'product'){
            divCat = 'cat_for_add_';
            selectCat = 'selectcatforadd';
        }else if(aryData.type == 'specs'){
            divCat = 'specs_cat_';
            selectCat = 'specsselectcat';
        }
        for(var i = aryData.selectId; i <= 5; i++){
            Dom.get(divCat+i).className = 'hide';
        }
        
        if(aryData.intOk == 1){
            
            
            Dom.get(divCat+aryData.selectId).className = 'show';

            var selectCatId = '';

            selectCatId = selectCat+aryData.selectId;
            
            var newsCatId = document.getElementById(selectCatId);
            var optLength = newsCatId.options.length;
            //            alert(optLength);
            //remove district
            if(optLength > 0){
                for(var n = optLength - 1; n >= 0; n-- ){
                    newsCatId.removeChild(newsCatId.options[n]);
                }
            }
            
            for (var property in aryData.aryCategory) {
                if (aryData.aryCategory.hasOwnProperty(property)) {
                    try{
                        var opt = document.createElement('OPTION');
                        opt.value = aryData.aryCategory[property]['category_id'];
                        if(aryData.aryCategory[property]['category_id'] == aryData.nextCatId){
                            opt.selected = true;
                        }
                        var categoryName = aryData.aryCategory[property]['category_name'];
                        
                        if(aryData.aryCategory[property]['category_total_child'] > 0){
                            categoryName+=' >';
                        }
                        if(navigator.appName.indexOf('Microsoft') !=-1){
                            opt.innerText = categoryName;
                        }else{
                            opt.text = categoryName;
                        }
                        newsCatId.appendChild(opt);
                        
                    }
                    catch(e){
                        alert(e.message);
                    }
                }
            }
        }
    },

    checkExistSpecs:function(specsId, selectId, nextSpecsId){
        if(nextSpecsId == undefined){
            nextSpecsId = 0;
        }
        Dom.get('specs_id').value = specsId;
        var strUrl = '/quanly/checkExistSpecs/?ajax=1&selectId='+selectId+'&specsId='+specsId+'&nextSpecsId='+nextSpecsId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.checkExistSpecsSuccess,
            failure: AdminController.adminRequestFalse
        });
    },

    checkExistSpecsSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        Dom.get('list_input_specs').innerHTML = '';
        var parentListSpecs = document.getElementById('list_input_specs');
        var newDiv = document.createElement('div');
        newDiv.id = 'item-0';
        newDiv.innerHTML = aryData.specsInputItem;
        parentListSpecs.appendChild(newDiv);
        
        Dom.get('specs_item_hidden').innerHTML = aryData.specsInputItem;
        if(aryData.specInputType != 3){
            Dom.get('btnSumitSpecs').className = 'show';
        }else{
            Dom.get('btnSumitSpecs').className = 'hide';
        }
        var divSpecs = 'specs_list_';
        
        var selectCat = 'specs_select_';

        for(var i = aryData.selectId; i <= 4; i++){
            Dom.get(divSpecs+i).className = 'hide';
        }

        if(aryData.intOk == 1){
            
            Dom.get(divSpecs+aryData.selectId).className = 'show';

            var selectCatId = selectCat+aryData.selectId;

            var newsCatId = document.getElementById(selectCatId);
            var optLength = newsCatId.options.length;
            
            if(optLength > 0){
                for(var n = optLength - 1; n >= 0; n-- ){
                    newsCatId.removeChild(newsCatId.options[n]);
                }
            }

            for (var property in aryData.arySpecs) {
                if (aryData.arySpecs.hasOwnProperty(property)) {
                    try{
                        var opt = document.createElement('OPTION');
                        opt.value = aryData.arySpecs[property]['specs_id'];
                        if(aryData.arySpecs[property]['specs_id'] == aryData.nextSpecsId){
                            opt.selected = true;
                        }
                        var specsName = aryData.arySpecs[property]['specs_name'];

                        if(aryData.arySpecs[property]['specs_total_child'] > 0){
                            specsName+=' >';
                        }
                        if(navigator.appName.indexOf('Microsoft') !=-1){
                            opt.innerText = specsName;
                        }else{
                            opt.text = specsName;
                        }
                        newsCatId.appendChild(opt);

                    }catch(e){
                        alert(e.message);
                    }
                }
            }
        }
    },

    hideProductEditor:function(){
        AdminController.showPlandProduct();
        AdminController.hiddenCenterDiv();
        Dom.get('list-product').className = 'show';
    },

    saveNews:function(type){
        AdminController.clearError();
        var newsContent= tinyMCE.get('news_content').getContent();
        Dom.get('news_content').value = newsContent;
        var strUrl = '/quanly/saveNews/?ajax=1&type='+type;
        YAHOO.util.Connect.setForm('frmAddNews', true);
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            upload: AdminController.saveNewsSuccess,
            failure: AdminController.adminRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    
    saveNewsSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            if(aryData.type == 'add'){
                AdminController.showOverlayConfirmYesNo(aryData.message, 'AdminController.showEditorAddNews();', 'AdminController.getListNews();');
            }else{
                AdminController.showOverlaySuccess(aryData.message);
                AdminController.getListNews(newsOrderType, newsCatNewsId, newsCatSubId, newsPage);
            }
        }
        else{
            AdminController.showOverlayError(aryData.messageError);
            AdminController.innerError(aryData.aryError);
        }
    },

    editNewsById:function(newsId){
        AdminController.hiddenCenterDiv();
        AdminController.clearError();
        var html = '<span>Cập nhật tin tức</span>';
        html+='<span style="cursor:pointer;margin-left:20px;color:red; text-decoration: underline;" onclick="AdminController.hideEditorAddNews();">Đóng</span>';
        Dom.get('manage-new-pland').innerHTML = '';
        Dom.get('manage-new-pland').innerHTML = html;
        Dom.get('submitAddNews').value = 'Cập nhật';
        document.getElementById('submitAddNews').setAttribute('onclick', "AdminController.saveNews('edit');");
        document.getElementById('editor-add-news').className = 'show';
        Dom.get('news_id').value = newsId;
        var strUrl = '/quanly/getDataForEditNews/?ajax=1&newsId='+newsId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.getDataNewsSuccess,
            failure: AdminController.adminRequestFalse
        });
    },

    getDataNewsSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Common.jsonToForm(aryData.data);
            tinyMCE.get('news_content').setContent(aryData.data.news_content);
            AdminController.selectNewsSub();
            Dom.get('news_new_sub_category_id').value = aryData.data.news_new_sub_category_id;
        }
    },

    hideEditorAddNews:function(){
        AdminController.showPlandNews();
        AdminController.hiddenCenterDiv();
        var element = 'title-list-news';
        AdminController.selectedHeaderControll(element);
        Dom.get('list-news').className = 'show';
    },

    manageMember:function(){
        
        var html = '<a id="title-member-1" onclick="AdminController.getListMember();">Danh sách thành viên</a>';
        html += '<a id="title-member-2" onclick="AdminController.showAddMember();">Thêm thành viên</a>';
        Dom.get('manage-new-pland').innerHTML = html;
        AdminController.getListMember('login-name-up', 1);
    },

    getListMember:function(oderType, page){
        if(oderType == undefined){
            oderType = 'login-name-up';
        }
        if(page == undefined){
            page = 1;
        }
        var elementSubId = 'title-member-1';
        var elementId = 'menu_6';
        //        AdminController.setlectedTopMenu(elementId);
        AdminController.hiddenCenterDiv();
        Dom.get('list_member').className = 'show';
        AdminController.selectedHeaderControll(elementSubId);
        var strUrl = '/quanly/getListMember/?ajax=1&page='+page+'&orderType='+oderType;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.getListMemberSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },

    getListMemberSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('list_member').innerHTML = aryData.listMember;
        }
    //        AdminController.getCategoryForPermission();
    },

    getCategoryForPermission:function(){
        var strUrl = '/quanly/getCategoryForPermission/?ajax=1';
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.getCategoryForPermissionSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },

    getCategoryForPermissionSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        Dom.get('per_product_category').innerHTML = aryData.productCategory;
        Dom.get('per_news_category').innerHTML = aryData.newsCategory;
    },

    showAddMember:function(){
        var elementId = 'title-member-2';
        AdminController.selectedHeaderControll(elementId);
        AdminController.hiddenCenterDiv();
        AdminController.resetForm('frmAddMember');
        Dom.get('form_add_member').className = 'show';
        Dom.get('submitAddMember').value = 'Thêm';
        document.getElementById('submitAddMember').setAttribute('onclick', "AdminController.saveMember('add');");
    },

    cancelAddMember:function(){
        Dom.get('list_member').className = 'show';
        Dom.get('form_add_member').className = 'hide';
    },

    checkExistMemember:function(){
        var loginName = Dom.get('member_login_name').value;
        var strUrl = '/quanly/checkExistMember/?ajax=1&loginName='+loginName;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.checkExistMememberSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },

    checkExistMememberSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('message_login_name_error').innerHTML = 'Tên đăng nhập này đã tồn tại.';
            Dom.get('member_login_name_error').innerHTML = '<img src="/public/images/form/delete.png">';
        }else{
            Dom.get('message_login_name_error').innerHTML = '';
            Dom.get('member_login_name_error').innerHTML = '<img src="/public/images/form/tick-icon.png">';
        }
    },

    saveMember:function(type){
        var strUrl = '/quanly/saveMember/?ajax=1&type='+type;
        YAHOO.util.Connect.setForm('frmAddMember');
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.saveMemberSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },

    saveMemberSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            if(aryData.type == 'add'){
                alert("Thành viên mới đã được thêm.");
            }else{
                alert('Thông tin thành viên đã được cập nhật.');
            }

            AdminController.getListMember();
           
        }else{
            alert(aryData.strError);
        }
    },

    showEditMember:function(memberId){
        this.hiddenCenterDiv();
        Dom.get('form_add_member').className = 'show';
        Dom.get('submitAddMember').value = 'Cập nhật';
        AdminController.resetForm('frmAddMember');
        Dom.get('member_id').value = memberId;
        document.getElementById('submitAddMember').setAttribute('onclick', "AdminController.saveMember('edit');");
        var strUrl = '/quanly/getMemberById/?ajax=1&memberId='+memberId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.showEditMemberSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    showEditMemberSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Common.jsonToForm(aryData.memberData);
            if(aryData.permissionProduct){
                Common.setValueByName('member_permission_product[]', aryData.permissionProduct);
            }
            if(aryData.permissionProductCategory){
                Common.setValueByName('member_permission_product_category[]', aryData.permissionProductCategory);
            }
            if(aryData.permissionNews){
                Common.setValueByName('member_permission_news[]', aryData.permissionNews);
            }
            if(aryData.permissionNewsCategory){
                Common.setValueByName('member_permission_news_category[]', aryData.permissionNewsCategory);
            }
            if(aryData.permissionOrder){
                Common.setValueByName('member_permission_orders[]', aryData.permissionOrder);
            }
            if(aryData.permissionEditData){
                Common.setValueByName('member_permission_data', aryData.permissionEditData);
            }
            
        }
    },

    formatCurrency:function(div_id, inputId){
        var str_number = Dom.get(inputId).value;
        if(AdminController.isNumber(str_number) == false){
            Dom.get(div_id).innerHTML = '';
            return;
        }
        Dom.get(div_id).innerHTML = AdminController.addCommas(str_number);
    },

    addCommas:function(nStr){
        nStr += '';
        var aryFloat = nStr.split('.');
        var floatNumberLengt = aryFloat.length;
        if(floatNumberLengt > 1 ){
            return nStr;
        }
        var x = nStr.split(',');
        var x1 = x[0];
        var x2 = "";
        x2 = x.length > 1 ? ',' + x[1] : '';
        var rgx = /(\d+)(\d{3})/;
        while (rgx.test(x1)) {
            x1 = x1.replace(rgx, '$1' + '.' + '$2');
        }
        return x1 + x2;
    },

    isNumber:function(number){
        if(number == ''){
            return false;
        }
        if (/^((\d\.?)*)$/.test(number)){
            return true;
        }else{
            return false;
        }
    },

    manageOrder:function(){
        AdminController.hiddenCenterDiv();
        AdminController.getProductOrder('all');
    },

    getProductOrder:function(type, page){
        AdminController.showPlanOrder();
        var elementId = '';
        if(type == 'new'){
            elementId = 'title-new-order';
        }
        if(type == 'isProcess'){
            elementId = 'title-old-order';
        }
        if(type == 'isWait'){
            elementId = 'title-wait-order';
        }
        if(page == undefined){
            page = 1;
        }
        orderType = type;
        orderPage = page;
        AdminController.hiddenCenterDiv();
        AdminController.selectedHeaderControll(elementId);
        var strUrl = '/quanly/getProductOrder/?ajax=1&type='+type+'&page='+page;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.getProductOrderSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },

    getProductOrderSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('list_order_content').className = 'show';
            Dom.get('list_order_content').innerHTML = aryData.orderContent;
        }
    },

    showPlanOrder:function(){
        var html = '';
        html += '<a id="title-new-order" onclick="AdminController.getProductOrder('+"'new'"+');">Đơn hàng mới</a>';
        html += '<a id="title-old-order" onclick="AdminController.getProductOrder('+"'isProcess'"+');">Đơn hàng đã xử lý</a>';
        html += '<a id="title-wait-order" onclick="AdminController.getProductOrder('+"'isWait'"+');">Đơn hàng đang chờ xử lý</a>';
        Dom.get('manage-new-pland').innerHTML = html;
    },

    viewDetailOrder:function(orderDetailId, type){
        var html = '<span>Xem chi tiết đơn hàng</span>';
        html+='<span style="cursor:pointer;margin-left:20px;color:red; text-decoration: underline;" onclick="AdminController.hideViewOrderDetail();">Đóng</span>';
        Dom.get('manage-new-pland').innerHTML = html;
        AdminController.hiddenCenterDiv();
        var strUrl = '/quanly/viewDetailOrder/?ajax=1&orderDetailId='+orderDetailId+'&type='+type;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.viewDetailOrderSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    
    viewDetailOrderSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('view_detail_order').className = 'show';
            Dom.get('view_detail_order').innerHTML = aryData.orderDetailContent;
        }
    },

    hideViewOrderDetail:function(){
        AdminController.hiddenCenterDiv();
        AdminController.showPlanOrder();
        AdminController.getProductOrder(orderType, orderPage);
    },

    updateStatusOrder:function(statusType, detailId){
        var orderComemnt = Dom.get('order_detail_comment').value;
        var strPost = 'orderComment='+orderComemnt;
        var strUrl = '/quanly/updateStatusOrder/?ajax=1&statusType='+statusType+'&detailId='+detailId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.updateStatusOrderSuccess,
            failure: AdminController.asyncRequestFalse
        },strPost);
    },
    
    updateStatusOrderSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
            AdminController.getProductOrder(orderType, orderPage);
        }
    },

    deleteOrder:function(orderId){
        if(confirm('Bạn chắc chắn muốn xóa đơn hàng này?') == false){
            return;
        }
        var strUrl = '/quanly/deleteOrder/?ajax=1&orderId='+orderId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.deleteOrderSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    deleteOrderSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
            AdminController.getProductOrder(orderType, 1);
        }
    },
    
    searchProduct:function(orderType, page){
        if(page == undefined){
            page = 1;
        }
        if(orderType == undefined){
            orderType = 'price-down';
        }
        AdminController.selectedHeaderControll('no_id');
        var strPost = '';
        strPost+='perProductAdd='+perProductAdd+'&perProductEdit='+perProductEdit+'&perProductDelete='+perProductDelete+'&isMaster='+isMaster;
        var strUrl = '/quanly/searchProduct/?ajax=1&page='+page+'&orderType='+orderType;
        YAHOO.util.Connect.setForm('search_product');
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.searchProductSuccess,
            failure: AdminController.asyncRequestFalse
        },strPost);
        YAHOO.util.Connect.resetFormState();
    },
    
    searchProductSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){            
            Dom.get('list_search_result').innerHTML = aryData.searchContent;
        }else if(aryData.intOk == 0){
            Dom.get('list_search_result').innerHTML = '';
        }else if(aryData.intOk == -2){
            AdminController.showOverlayError(aryData.strError);
        }
    },
    
    manageSlider:function(){
        AdminController.hiddenCenterDiv();
        AdminController.getSlider('active', 1);
    },

    sliderPland:function(){
        var html = '';
        html += '<a id="title-slider-active" onclick="AdminController.getSlider('+"'active'"+');">Slider đang kích hoạt</a>';
        html += '<a id="title-slider-del" onclick="AdminController.getSlider('+"'delete'"+');">Slider đã xóa</a>';
        html += '<a id="title-add-slider" onclick="AdminController.addSlider();">Thêm slider</a>';
        Dom.get('manage-new-pland').innerHTML = html;
    },

    getSlider:function(type, page){
        AdminController.sliderPland();
        var elementId = '';
        if(type == 'active'){
            elementId = 'title-slider-active';
        }
        if(type == 'delete'){
            elementId = 'title-slider-del';
        }
        if(page == undefined){
            page = 1;
        }
        sliderType = type;
        sliderPage = page;
        AdminController.hiddenCenterDiv();
        AdminController.selectedHeaderControll(elementId);
        var strUrl = '/quanly/getListSlider/?ajax=1&type='+type+'&page='+page;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.getSliderSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },

    getSliderSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('list_slider').className = 'show';
            Dom.get('list_slider').innerHTML = aryData.listSlider;
        }
    },

    addSlider:function(){
        var elementId = 'title-add-slider';
        AdminController.selectedHeaderControll(elementId);
        AdminController.hiddenCenterDiv();
        Dom.get('form_add_slider').className = 'show';
    },

    saveSlider:function(){
        var strUrl = '/quanly/saveSlider/?ajax=1';
        YAHOO.util.Connect.setForm('frmAddSlider', true);
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            upload: AdminController.saveSliderSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    
    saveSliderSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
            AdminController.getSlider('active');
        }else{
            AdminController.showOverlayError(aryData.strError);
        }
    },

    editSlider:function(sliderId){
        var strUrl = '/quanly/editSliderById/?ajax=1&sliderId='+sliderId;
        YAHOO.util.Connect.setForm('frmEditSlider'+sliderId, true);
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            upload: AdminController.editSliderSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    editSliderSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.getSlider(sliderType, sliderPage);
            AdminController.showOverlaySuccess(aryData.message);
        }else{
            AdminController.showOverlayError(aryData.strError);
        }
    },

    showEditSlider:function(sliderId){
        Dom.get('slider'+sliderId).className = 'show';
    },

    cancelEditSlider:function(sliderId){
        Dom.get('slider'+sliderId).className = 'hide';
    },
    
    deleteSlider:function(sliderId){
        var strUrl = '/quanly/deleteSlider/?ajax=1&sliderId='+sliderId+'&page='+sliderPage;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.deleteSliderSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    
    deleteSliderSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
            AdminController.getSlider(sliderType, aryData.returnPage);
        }
    },

    checkExistNewsCategory:function(newsCatId, selectId){
        Dom.get('news_cat_id_hidden').value = newsCatId;
        var strUrl = '/quanly/checkExistNewsCategory/?ajax=1&selectId='+selectId+'&newsCategoryId='+newsCatId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.checkNewsCatSuccess,
            failure: AdminController.adminRequestFalse
        });
    },
    
    checkNewsCatSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        var divCat = 'news_';
        var selectCat = 'selectnews';
        
        for(var i = aryData.selectId; i <= 2; i++){
            Dom.get(divCat+i).className = 'hide';
        }

        if(aryData.intOk == 1){


            Dom.get(divCat+aryData.selectId).className = 'show';

            var selectCatId = '';

            selectCatId = selectCat+aryData.selectId;

            var newsCatId = document.getElementById(selectCatId);
            var optLength = newsCatId.options.length;
            //            alert(optLength);
            //remove district
            if(optLength > 0){
                for(var n = optLength - 1; n >= 0; n-- ){
                    newsCatId.removeChild(newsCatId.options[n]);
                }
            }

            for (var property in aryData.aryCategory) {
                if (aryData.aryCategory.hasOwnProperty(property)) {
                    try{
                        var opt = document.createElement('OPTION');
                        opt.value = aryData.aryCategory[property]['news_category_id'];
                        if(aryData.aryCategory[property]['news_category_id'] == aryData.nextCatId){
                            opt.selected = true;
                        }
                        var categoryName = aryData.aryCategory[property]['news_category_name'];

                        if(aryData.aryCategory[property]['news_category_total_child'] > 0){
                            categoryName+=' >';
                        }
                        if(navigator.appName.indexOf('Microsoft') !=-1){
                            opt.innerText = categoryName;
                        }else{
                            opt.text = categoryName;
                        }
                        newsCatId.appendChild(opt);

                    }catch(e){
                        alert(e.message);
                    }
                }
            }
        }
    },

    saveNewsCategoryById:function(newsCatId, ulId, parentNewsCatId){
        var strUrl = '/quanly/editNewsCategoryById/?ajax=1';
        var categoryName = Dom.get('input_cat_'+newsCatId).value;
        var strPost = 'categoryName='+categoryName;
        strPost+='&categoryId='+newsCatId;
        strPost+='&ulId='+ulId;
        strPost+='&parentId='+parentNewsCatId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.saveNewsCategoryByIdSuccess,
            failure: AdminController.asyncRequestFalse
        },strPost);
    },
    
    saveNewsCategoryByIdSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
            AdminController.getListNewsCategory(aryData.parentId, aryData.ulId);
        }else{
            AdminController.showOverlayError(aryData.strError);
        }
    },

    editNewsProductCategory:function(newsCategoryId){
        var productCategoryId = Dom.get('product_category_id').value;
        var strUrl = '/quanly/editNewsProductCategory/?ajax=1&newsCatId='+newsCategoryId+'&productCatId='+productCategoryId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.editNewsProductCategorySuccess,
            failure: AdminController.asyncRequestFalse
        });
    },

    editNewsProductCategorySuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
        }else{
            AdminController.showOverlayError(aryData.strError);
        }
    },

    manageCommon:function(){
        Dom.get('manage-new-pland').innerHTML = '';
        AdminController.hiddenCenterDiv();
    },

    manageGeneral:function(type){
        AdminController.hiddenCenterDiv();
        Dom.get('manage-new-pland').innerHTML = '';
        switch (type) {
            case "currency":
                Dom.get('manage_curency').className = 'show';
                break;
        }

        var strUrl = '/quanly/getTemplateManageGeneral/?ajax=1&type='+type;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.manageGeneralSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },

    manageGeneralSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        switch (aryData.type) {
            case "currency":
                Dom.get('common_currency').value = aryData.manageData.common_currency;
                break;
        }

    },
    
    saveCurrency:function(){
        var strUrl = '/quanly/saveCurrency/?ajax=1';
        YAHOO.util.Connect.setForm('frmManageCurrency');
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.saveCurrencySuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    
    saveCurrencySuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
            AdminController.manageGeneral('currency');
        }else{
            AdminController.showOverlayError(aryData.strError);
        }
    },

    showConfirmNewsDelete:function(newsId){
        AdminController.showOverlayConfirmYesNo('Bạn chắc chắn muốn xóa tin này?', 'AdminController.deleteNewsById("'+newsId+'");', 'AdminController.closeOverlayConfirmYesNo();');
    },

    deleteNewsById:function(newsId){
        var strUrl = '/quanly/deleteNewsById/?ajax=1&newsId='+newsId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.deleteNewsByIdSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },

    deleteNewsByIdSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
            AdminController.getListNews(newsOrderType, newsCatNewsId, newsCatSubId, newsPage);
        }
    },

    changeUsdToVnd:function(){
        var priceUsd = Dom.get('product_price_usd').value;
        var strUrl = '/quanly/changeCurrency/?ajax=1&priceUsd='+priceUsd;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.changeUsdToVndSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    
    changeUsdToVndSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('product_price_vnd').value = aryData.priceVnd;
            AdminController.formatCurrency('change_price_1', 'product_price_vnd');
        }else{
            Dom.get('change_price_usd').innerHTML = aryData.strError;
            Dom.get('product_price_vnd').value = '';
            Dom.get('change_price_1').innerHTML = '';
        }
    },

    changeVndToUsd:function(){
        var priceVnd = Dom.get('product_price_vnd').value;
        var strUrl = '/quanly/changeVndToUsd/?ajax=1&priceVnd='+priceVnd;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.changeVndToUsdSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    
    changeVndToUsdSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('product_price_usd').value = aryData.priceUsd;
            AdminController.formatCurrency('change_price_usd', 'product_price_usd');
        }else{
            Dom.get('change_price_1').innerHTML = aryData.strError;
            Dom.get('product_price_usd').value = '';
            Dom.get('change_price_usd').innerHTML = '';
        }
    },

    showCustommerLinkPlan:function(){
        var html = '';
        html += '<a id="link-all" onclick="AdminController.showCustomerProductLink('+"'new'"+');">Yêu cầu mới</a>';
        html += '<a id="link-processed" onclick="AdminController.showCustomerProductLink('+"'processed'"+');">Đã xử lý</a>';
        html += '<a id="link-processing" onclick="AdminController.showCustomerProductLink('+"'processing'"+');">Đang xử lý</a>';
        Dom.get('manage-new-pland').innerHTML = html;
    },
    
    showCustomerProductLink:function(type){
        var elementId = '';
        switch (type) {
            case 'new':
                elementId = 'link-all';
                break;
            case 'processed':
                elementId = 'link-processed';
                break;
            case 'processing':
                elementId = 'link-processing';
                break;
        }
        AdminController.hiddenCenterDiv();
        AdminController.showCustommerLinkPlan();
        AdminController.selectedHeaderControll(elementId);
        var strUrl = '/quanly/showCustomerProductLink/?ajax=1&type='+type;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.showCustomerLinkSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    showCustomerLinkSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        Dom.get('customer_link').className = 'show';
        Dom.get('customer_link').innerHTML = aryData.content;
        
    },
    viewDetailCustomerLink:function(custommerId, productId){
        AdminController.hiddenCenterDiv();
        AdminController.showCustommerLinkPlan();
        var strUrl = '/quanly/viewDetailCustomerLink/?ajax=1&custommerId='+custommerId+'&productId='+productId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.viewDetailCustomerLinkSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },

    viewDetailCustomerLinkSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('customer_link_detail').className = 'show';
            Dom.get('customer_link_detail').innerHTML = aryData.content;
        }
    },
    updateStatusCustomerLink:function(statusId){
        var strUrl = '/quanly/updateStatusCustomerLink/?ajax=1&statusId='+statusId;
        YAHOO.util.Connect.setForm('frmUpdateStatusLink');
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.updateStatusCustomerLinkSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    updateStatusCustomerLinkSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
            AdminController.showCustomerProductLink('all');
        }
    },

    confirmDeleteMember:function(memberId){
        AdminController.showOverlayConfirmYesNo('Bạn chắc chắn muốn xóa thành viên này', 'AdminController.deleteMember('+memberId+');', 'AdminController.closeOverlayConfirmYesNo();');
    },

    deleteMember:function(memberId){
        var strUrl = '/quanly/deleteMember/?ajax=1&memberId='+memberId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.deleteMemberSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    deleteMemberSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
            AdminController.getListMember();
        }
    },

    confirmDeleteCustomer:function(CustomerId){
        AdminController.showOverlayConfirmYesNo('Bạn chắc chắn muốn xóa thành viên này', 'AdminController.deleteCustomer('+CustomerId+');', 'AdminController.closeOverlayConfirmYesNo();');
    },

    deleteCustomer:function(CustomerId){
        var strUrl = '/quanly/deleteCustomer/?ajax=1&CustomerId='+CustomerId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.deleteCustomerSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    deleteCustomerSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
            AdminController.getListCustomer();
        }
    },

    getListCustomer:function(page){
        if(page == undefined){
            page = 1;
        }
        AdminController.hiddenCenterDiv();
        Dom.get('customer_list_customer').className = 'show';
        var strUrl = '/quanly/getListCustomer/?ajax=1&page='+page;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.getListCustomerSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },

    getListCustomerSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('customer_list_customer').innerHTML = aryData.list_customer;
        }
    },

    showMyCtvPlan:function(){
        var html = '';
        html += '<a id="my_ctv_list" onclick="AdminController.getMyCtv();">Danh sách cộng tác viên</a>';
        html += '<a id="my_ctv_add" onclick="AdminController.showAddMyCtv();">Thêm cộng tác viên</a>';
        Dom.get('manage-new-pland').innerHTML = html;
    },

    getMyCtv:function(page){
        AdminController.hiddenCenterDiv();
        AdminController.showMyCtvPlan();
        var elementId = 'my_ctv_list';
        AdminController.selectedHeaderControll(elementId);
        if(page == undefined){
            page = 1;
        }
        Dom.get('ctv_list_my_ctv').className = 'show';
        var strUrl = '/quanly/getMyCtv/?ajax=1&page='+page;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.getMyCtvSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },

    getMyCtvSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        Dom.get('ctv_list_my_ctv').innerHTML = aryData.list_my_ctv;
    },
    
    getListCustomerCTV:function(page){
        if(page == undefined){
            page = 1;
        }
        AdminController.hiddenCenterDiv();
        Dom.get('customer_list_CTV').className = 'show';
        var strUrl = '/quanly/getCustomerCTV/?ajax=1&page='+page;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.getListCustomerCTVSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },

    getListCustomerCTVSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('customer_list_CTV').innerHTML = aryData.list_customer;
        }
    },

    viewDetailMyCtv:function(custommerId){
        AdminController.hiddenCenterDiv();
        Dom.get('list_statistics_ctv').className = 'show';
        Dom.get('ctv_list_my_ctv').className = 'show';
        var strUrl = '/quanly/viewDetailMyCtv/?ajax=1&custommerId='+custommerId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.viewDetailMyCtvSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    
    viewDetailMyCtvSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('list_statistics_ctv').innerHTML = aryData.content;
        }
    },

    

    viewDetailSearchDoanhSo:function(custommerId){
        AdminController.hiddenCenterDiv();
        Dom.get('ctv_view_detail').className = 'show';
        var strUrl = '/quanly/viewDetailSearchDoanhSo/?ajax=1&custommerId='+custommerId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.viewDetailSearchDoanhSoSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },

    viewDetailSearchDoanhSoSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('ctv_view_detail').innerHTML = aryData.content;
        }
    },

    viewDetailDoanhsoCtv:function(custommerId){
        YAHOO.util.Connect.setForm('frmSearchCtvProduct');
        var strUrl = '/quanly/viewDetailDoanhsoCtv/?ajax=1&custommerId='+custommerId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.viewDetailDoanhsoCtvSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },

    viewDetailDoanhsoCtvSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('list_statistics_ctv').innerHTML = aryData.content;
        }
    },

    viewDetailSearchMyCtv:function(custommerId){
        YAHOO.util.Connect.setForm('frmSearchMyCtv');
        var strUrl = '/quanly/viewDetailSearchMyCtv/?ajax=1&custommerId='+custommerId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.viewDetailSearchMyCtvSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },

    viewDetailSearchMyCtvSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('list_statistics_ctv').innerHTML = aryData.content;
        }
    },

    showMyCustomerPlan:function(){
        var html = '';
        html += '<a id="my_list_customer" onclick="AdminController.showListMyCustomer();">Khách hàng của tôi</a>';
        html += '<a id="my_add_customer" onclick="AdminController.getMyCtv();">Thêm khách hàng</a>';
        Dom.get('manage-new-pland').innerHTML = html;
    },

    showListMyCustomer:function(){
        AdminController.hiddenCenterDiv();
        AdminController.showMyCustomerPlan();
    },

    addProductForCtv:function(){
        AdminController.clearError();
        var strUrl = '/quanly/addProductForCtv/?ajax=1';
        YAHOO.util.Connect.setForm('frmEditProductCustomer');
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.addProductForCtvSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    
    addProductForCtvSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
            AdminController.viewDetailMyCtv(aryData.customerId);
        }else{
            AdminController.innerError(aryData.aryError);
        }
    },

    saveEditProductForCtv:function(type){
        AdminController.clearError();
        var strUrl = '/quanly/saveEditProductForCtv/?ajax=1&type='+type;
        YAHOO.util.Connect.setForm('frmEditProductCustomer');
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.saveEditProductForCtvSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },

    saveEditProductForCtvSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
            if(aryData.type == 'ketoan'){
                AdminController.viewDetailDoanhsoCtv(aryData.customer_id);
            }else if(aryData.type == 'kd'){
                AdminController.viewDetailSearchMyCtv(aryData.customer_id);
            }else if(aryData.type == 'kd_default'){
                AdminController.viewDetailMyCtv(aryData.customer_id);
            }
            
        }else{
            AdminController.innerError(aryData.aryError);
        }
    },

    statisticsPland:function(){
        var html = '';
        html += '<a id="list_statistics" onclick="AdminController.statisticsProfit();">Danh sách thống kê</a>';
        Dom.get('manage-new-pland').innerHTML = html;
    },

    statisticsProfit:function(memberId, page){
        if(page == undefined){
            page = 1;
        }
        if(memberId == undefined){
            memberId = 0;
        }
        AdminController.hiddenCenterDiv();
        AdminController.statisticsPland();
        var elementId = 'list_statistics';
        AdminController.selectedHeaderControll(elementId);
        Dom.get('ctv_list_my_ctv').className = 'show';
        var strUrl = '/quanly/statisticsProfit/?ajax=1&page='+page+'&memberId='+memberId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.statisticsProfitSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    
    statisticsProfitSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('ctv_list_my_ctv').innerHTML = aryData.list_my_ctv;
            Dom.get('list-category').innerHTML = aryData.list_kd;
        }
    },

    searchCtvProduct:function(memberId, page){
        if(page == undefined){
            page = 1;
        }
        if(memberId == undefined){
            memberId = 0;
        }
        YAHOO.util.Connect.setForm('frmSearchCtvProduct');
        var strUrl = '/quanly/searchCtvProduct/?ajax=1&page='+page+'&memberId='+memberId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.searchCtvProductSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    
    searchCtvProductSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        Dom.get('list-category').innerHTML = aryData.list_kd;
        Dom.get('customer_product_kd_id').value = aryData.memberId;
        if(aryData.intOk == 1){
            Dom.get('list_statistics_ctv').innerHTML = aryData.list_statistics_ctv;
            
        }else if(aryData.intOk == 0){
            Dom.get('list_statistics_ctv').innerHTML = '';
        }else if(aryData.intOk == -2){
            AdminController.showOverlayError(aryData.message);
        }
    },

    searchMyCtv:function(page){
        if(page == undefined){
            page = 1;
        }
        YAHOO.util.Connect.setForm('frmSearchMyCtv');
        var strUrl = '/quanly/searchMyCtv/?ajax=1&page='+page;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.searchMyCtvSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },

    searchMyCtvSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        Dom.get('list-category').innerHTML = '';
        if(aryData.intOk == -2){
            AdminController.showOverlayError(aryData.message);
        }else{
            Dom.get('list_statistics_ctv').innerHTML = aryData.list_my_ctv;
        }
    },

    finishProductStatucs:function(){
        YAHOO.util.Connect.setForm('updateFinishStatus');
        var strUrl = '/quanly/finishProductStatucs/?ajax=1';
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.finishProductStatucsSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    
    finishProductStatucsSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
            AdminController.viewDetailDoanhsoCtv(aryData.customer_id);
        }else{
            AdminController.showOverlayError(aryData.message);
        }
    },

    editCtvProduct:function(ctvProductId){
        if(Dom.get('edit_ctv_product')){
            Dom.get('edit_ctv_product').value = 'Cập nhật lại sản phẩm';
            Dom.get('edit_ctv_product').setAttribute('onclick', "AdminController.saveEditProductForCtv('kd_default');");
        }
        if(Dom.get('title_add_ctv_product')){
            Dom.get('title_add_ctv_product').className = 'hide';
            Dom.get('title_update_ctv_product').className = 'show';
        }
        if(Dom.get('cancel_edit_ctv_product')){
            Dom.get('cancel_edit_ctv_product').className = 'show';
        }
        Dom.get('frmEditProductCustomer').className = 'show';
        AdminController.clearError();
        var strUrl = '/quanly/editCtvProduct/?ajax=1&ctvProductId='+ctvProductId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.editCtvProductSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },

    editCtvProductSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Common.jsonToForm(aryData.data);
        }else{
    //            AdminController.showOverlayError(aryData.message);
    }
    },
    
    cancelEditCtvProduct:function(){
        if(Dom.get('edit_ctv_product')){
            Dom.get('edit_ctv_product').value = 'Thêm sản phẩm';
            Dom.get('edit_ctv_product').setAttribute('onclick', "AdminController.addProductForCtv();");
        }
        if(Dom.get('title_add_ctv_product')){
            Dom.get('title_add_ctv_product').className = 'show';
            Dom.get('title_update_ctv_product').className = 'hide';
        }
        if(Dom.get('cancel_edit_ctv_product')){
            Dom.get('cancel_edit_ctv_product').className = 'hide';
        }
        AdminController.clearError();
        AdminController.resetForm('frmEditProductCustomer');
    },

    showAddMyCtv:function(){
        var elementId = 'my_ctv_add';
        AdminController.selectedHeaderControll(elementId);
        AdminController.hiddenCenterDiv();
        AdminController.resetForm('frmAddMyCtv');
        Dom.get('editor_add_my_ctv').className = 'show';
    },
    
    saveMyCtv:function(){
        AdminController.clearError();
        YAHOO.util.Connect.setForm('frmAddMyCtv');
        var strUrl = '/quanly/saveMyCtv/?ajax=1';
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.saveMyCtvSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    
    saveMyCtvSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
            AdminController.getMyCtv();
        }else{
            AdminController.innerError(aryData.aryError);
        }
    },

    getMyProfitPlan:function(){
        var html = '';
        html += '<a id="list_my_profit" onclick="AdminController.getMyProfit();">Thống kê doanh số</a>';
        html += '<a id="list_my_customer" onclick="AdminController.getMyCustomer();">Thống kê khách hàng</a>';
        html += '<a id="add_my_product" onclick="AdminController.showAddMyProduct();">Thêm sản phẩm</a>';
        Dom.get('manage-new-pland').innerHTML = html;
    },
    
    getMyProfit:function(){
        AdminController.getMyProfitPlan();
        AdminController.hiddenCenterDiv();
        var elementId = 'list_my_profit';
        AdminController.selectedHeaderControll(elementId);
        var strUrl = '/quanly/getMyProfit/?ajax=1';
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.getMyProfitSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    
    getMyProfitSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('kd_list_my_profit').className = 'show';
            Dom.get('kd_list_my_profit').innerHTML = aryData.content;
        }
    },


    showAddMyProduct:function(){
        AdminController.getMyProfitPlan();
        AdminController.hiddenCenterDiv();
        AdminController.clearError();
        AdminController.resetForm('frmAddMyProduct');
        AdminController.resetForm('frmSearchCustomerInfo');
        var elementId = 'add_my_product';
        AdminController.selectedHeaderControll(elementId);
        Dom.get('kd_add_my_product').className = 'show';
    },
    
    addMyProduct:function(){
        AdminController.clearError();
        YAHOO.util.Connect.setForm('frmAddMyProduct');
        var strUrl = '/quanly/addMyProduct/?ajax=1';
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.addMyProductSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    addMyProductSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
        }else{
            AdminController.innerError(aryData.aryError);
        }
    },
    
    searchCustomerInfo:function(page){
        if(page == undefined){
            page = 1;
        }
        YAHOO.util.Connect.setForm('frmSearchCustomerInfo');
        var strUrl = '/quanly/searchCustomerInfo/?ajax=1&page='+page;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.searchCustomerInfoSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    searchCustomerInfoSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        Dom.get('search_list_customer').className = 'show';
        
        Dom.get('search_list_customer').innerHTML = aryData.content;
    },

    viewDetailSearchCustomer:function(customerId){
        var strUrl = '/quanly/viewDetailSearchCustomer/?ajax=1&customerId='+customerId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.viewDetailSearchCustomerSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
   
    viewDetailSearchCustomerSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        Dom.get('resetCustomerInfo').className = 'show';
        if(aryData.intOk == 1){
            Common.jsonToForm(aryData.data);
        }
    },
    resetCustomerInfo:function(){
        AdminController.resetForm('frmAddMyProduct');
        Dom.get('customer_id').value = '';
    },
    searchMyProfit:function(page){
        if(page == undefined){
            page = 1;
        }
        AdminController.hiddenCenterDiv();
        Dom.get('kd_list_my_product').className = 'show';
        Dom.get('kd_list_my_profit').className = 'show';
        YAHOO.util.Connect.setForm('frmSearchMyProfit');
        var strUrl = '/quanly/searchMyProfit/?ajax=1&page='+page;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.searchMyProfitSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    searchMyProfitSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        Dom.get('kd_list_my_product').innerHTML = aryData.content;
    },
    editMyProductAndMyCustomer:function(productId, customerId){
        Dom.get('kd_list_my_product').className = 'hide';
        Dom.get('kd_view_detail_my_product').className = 'show';
        var strUrl = '/quanly/editMyProductAndMyCustomer/?ajax=1&productId='+productId+'&customerId='+customerId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.editMyProductAndCusSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    
    editMyProductAndCusSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            Dom.get('kd_view_detail_my_product').innerHTML = aryData.content;
        }
    },
    closeFormViewMyProduct:function(){
        Dom.get('kd_list_my_product').className = 'show';
        Dom.get('kd_view_detail_my_product').className = 'hide';
    },

    editMyProduct:function(type, productId, customerId){
        var strUrl = '/quanly/editMyProduct/?ajax=1&type='+type+'&productId='+productId+'&customerId='+customerId;
        YAHOO.util.Connect.setForm('frmEditMyProduct');
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.editMyProductSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    
    editMyProductSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
        }
    },
    
    getMyCustomer:function(page){
        if(page==undefined){
            page = 1;
        }
        var elementId = 'list_my_customer';
        AdminController.selectedHeaderControll(elementId);
        AdminController.hiddenCenterDiv();
        Dom.get('kd_list_my_customer').className = 'show';
        var strUrl = '/quanly/getMyCustomer/?ajax=1&page='+page;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.getMyCustomerSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    getMyCustomerSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        Dom.get('kd_list_my_customer').innerHTML = aryData.content;
    },
    searchMyCustomerInfo:function(page){
        if(page == undefined){
            page = 1;
        }
        YAHOO.util.Connect.setForm('frmSearchMyCustomerInfo');
        var strUrl = '/quanly/searchMyCustomerInfo/?ajax=1&page='+page;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.searchMyCustomerInfoSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    searchMyCustomerInfoSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        Dom.get('view_detail_my_customer').className = 'hide';
        Dom.get('search_list_my_customer').className = 'show';
        Dom.get('search_list_my_customer').innerHTML = aryData.content;
    },
    viewDetailMyCustomer:function(customerId){
        var strUrl = '/quanly/viewDetailMyCustomer/?ajax=1&customerId='+customerId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.viewDetailMyCustomerSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    viewDetailMyCustomerSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        Dom.get('search_list_my_customer').className = 'hide';
        Dom.get('view_detail_my_customer').className = 'show';
        Dom.get('view_detail_my_customer').innerHTML = aryData.content;
    },
    showEditCustomerCtv:function(customerCtvId){
        Dom.get('list_customer_is_ctv').className = 'hide';
        Dom.get('edit_customer_ctv_info').className = 'show';
        var strUrl = '/quanly/showEditCustomerCtv/?ajax=1&customerCtvId='+customerCtvId;
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.showEditCustomerSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    showEditCustomerSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        Common.jsonToForm(aryData.data);
    },
    closeFormEditCtvInfo:function(){
        AdminController.resetForm('frmEditCustomerCtv');
        Dom.get('list_customer_is_ctv').className = 'show';
        Dom.get('edit_customer_ctv_info').className = 'hide';
    },
    changePassword:function(){
        AdminController.hiddenCenterDiv();
        var html = '';
        html += '<a onclick="AdminController.changePassword();">Thay đổi mật khẩu</a>';
        Dom.get('manage-new-pland').innerHTML = html;
        AdminController.resetForm('frmChangePass');
        Dom.get('change_pasword').className = 'show';
    },

    savePassword:function(){
        AdminController.clearError();
        var strUrl = '/quanly/savePassword/?ajax=1';
        YAHOO.util.Connect.setForm('frmChangePass');
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.savePasswordSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    
    savePasswordSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
            AdminController.resetForm('frmChangePass');
        }else{
            AdminController.innerError(aryData.aryError);
            AdminController.showOverlayError(aryData.strError);

        }
    },
    introductionPlan:function(){
        var html = '';
        html += '<a id="title_add_introduction" onclick="AdminController.manageIntroduction();">Giới thiệu</a>';
        Dom.get('manage-new-pland').innerHTML = html;
    },
    
    manageIntroduction:function(){
        AdminController.introductionPlan();
        AdminController.hiddenCenterDiv();
        var elementId = 'title_add_introduction';
        AdminController.selectedHeaderControll(elementId);
        AdminController.getIntroduction();
    },
    
    getIntroduction:function(){
        Dom.get('manageIntroduction').className = 'show';
        var strUrl = '/quanly/getIntroduction/?ajax=1';
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.getIntroductionSuccess,
            failure: AdminController.asyncRequestFalse
        });
    },
    
    getIntroductionSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        Dom.get('common_gioithieu_title').value = aryData.data.common_gioithieu_title;
        tinyMCE.get('common_gioi_thieu').setContent(aryData.data.common_gioi_thieu);
    },
    
    updateIntroduction:function(){
        AdminController.clearError();
        var introductionContent= tinyMCE.get('common_gioi_thieu').getContent();
        Dom.get('common_gioi_thieu').value = introductionContent;
        var strUrl = '/quanly/updateIntroduction/?ajax=1';
        YAHOO.util.Connect.setForm('frmAddIntroduction');
        YAHOO.util.Connect.asyncRequest ('POST', strUrl, {
            success: AdminController.updateIntroductionSuccess,
            failure: AdminController.asyncRequestFalse
        });
        YAHOO.util.Connect.resetFormState();
    },
    
    updateIntroductionSuccess:function(xmlhttp){
        var strJsonData = xmlhttp.responseText;
        var aryData = Json.parse(strJsonData);
        if(aryData.intOk == 1){
            AdminController.showOverlaySuccess(aryData.message);
        }else{
            AdminController.showOverlayError(aryData.message);
            AdminController.innerError(aryData.aryError);
        }
    }

}
